﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing.Printing;
using System.ComponentModel;


namespace NetRosApp.Klijenti
{
    static class PrinterUtility
    {
        static private string _printertoPrint = null;

        static private readonly PrinterSettings settings = new PrinterSettings();
        private static int _kopija = 1;
        public static string[] GetPrintere()
        {
            string[] _array = new string[PrinterSettings.InstalledPrinters.Count];
            PrinterSettings.InstalledPrinters.CopyTo(_array, 0);
            return _array;
        }

        public static string GetPrinterToPrinter()
        {
            if (String.IsNullOrEmpty(_printertoPrint))
            {
                //for (int i = 0; i < PrinterSettings.InstalledPrinters.Count; i++)
                //{

                //    settings.PrinterName = PrinterSettings.InstalledPrinters[i];
                //    //settings.CreateMeasurementGraphics();
                //    if (settings.IsDefaultPrinter)
                //        _printertoPrint = settings.PrinterName;
                //}
                foreach (string printerName in PrinterSettings.InstalledPrinters)
                {

                    settings.PrinterName = printerName;
                    //settings.CreateMeasurementGraphics();
                    if (settings.IsDefaultPrinter)
                        _printertoPrint = settings.PrinterName;

                }
            }
            return _printertoPrint;
        }
        public static void SetPrinterToPrint(String _printertoprint)
        {
            _printertoPrint = _printertoprint;
            settings.PrinterName = _printertoprint;
        }
        public static int BrojKopija
        {
            get { return _kopija; }
            set { _kopija = value; }
        }

        private static int _preglediliispis = 0;
        public static int PreglediliIspis
        {
            get { return _preglediliispis; }
            set { _preglediliispis = value; }
        }
        //static private string _printertoPrint = null;

        //static private readonly PrinterSettings settings = new PrinterSettings();
        //private static int _kopija = 1;
        //public static string[] GetPrintere()
        //{
        //    string[] _array = new string[PrinterSettings.InstalledPrinters.Count];
        //    PrinterSettings.InstalledPrinters.CopyTo(_array, 0);
        //    return _array;
        //}

        //public static string GetPrinterToPrinter()
        //{
        //    if (String.IsNullOrEmpty(_printertoPrint))
        //    {
        //        for (int i = 0; i < PrinterSettings.InstalledPrinters.Count; i++)
        //        {

        //            settings.PrinterName = PrinterSettings.InstalledPrinters[i];
        //            //settings.CreateMeasurementGraphics();
        //            if (settings.IsDefaultPrinter)
        //                _printertoPrint = settings.PrinterName;
        //        }
        //    }
        //    return _printertoPrint;
        //}
        //public static void SetPrinterToPrint(String _printertoprint)
        //{
        //    _printertoPrint = _printertoprint;
        //    settings.PrinterName = _printertoprint;
        // }
        //public static int BrojKopija
        //{
        //    get { return _kopija; }
        //    set { _kopija = value; }
        //}

        //private static int _preglediliispis = 0;
        //public static int PreglediliIspis
        //{
        //    get { return _preglediliispis; }
        //    set { _preglediliispis = value; }
        //}

    }
}
